home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Documents / OOPClass / Labs / RPNCalculator / Solution / RPNCalculatorMain.m < prev    next >
Encoding:
Text File  |  1991-07-31  |  859 b   |  40 lines

  1.  
  2. // Main program for testing the Stack object 
  3.  
  4. //SOLUTION
  5.  
  6. #import <stdio.h>
  7. #import "RPNCalculator.h"
  8.  
  9. main ( argc, argv )
  10. int argc;
  11. char *argv[];
  12. {
  13.     id calc;
  14.     
  15.     printf("\nCreate an RPNCalculator instance...\n");
  16.         calc = [[RPNCalculator alloc] init];    //allocate and initialize
  17.  
  18.     printf("Enter numbers 5.0, -10.0, -20.0, and 15.0 ...\n");;  // and print the stack
  19.         [calc  enter:5.0];
  20.         [calc  enter:-10.0];
  21.         [calc  enter:-20.0];
  22.         [calc  enter:15.0];
  23.         [calc printStack];
  24.                 
  25.     printf("Add...\n");;  // and print the stack
  26.         [calc add];
  27.         [calc printStack];
  28.     
  29.     printf("Subtract...\n");;  // and print the stack
  30.         [calc  subtract];
  31.         [calc printStack];
  32.     
  33.     printf("Clear the calculator's stack...\n");;  // and print the stack
  34.         [calc allClear];
  35.         [calc printStack];
  36.     
  37.     printf("Free the calculator and its  stack...\n");
  38.         [calc  free];
  39. } // end of program
  40.